package com.fhzn.auth.enums;

import lombok.Getter;

/**
 * @author fhzn
 */
@Getter
public enum ResourceTypeEnum {

    /**
     * 菜单
     */
    MENU(1, "菜单"),

    /**
     * 操作
     */
    OPERATION(2, "操作"),

    /**
     * 内嵌页面
     */
    INNERPAGE(3, "内嵌页面"),

    /**
     * 其它
     */
    OTHER(4, "其它"),

    /**
     * 数据库
     */
    DATABASE(6, "数据库"),

    /**
     * 数据库表
     */
    TABLE(5, "数据库表"),

    /**
     * 数据权限
     */
    DATASOURCE(7, "数据权限");


    private final int type;

    private final String name;

    ResourceTypeEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }

    public static ResourceTypeEnum getByType(int type) {
        for (ResourceTypeEnum tmp : ResourceTypeEnum.values()) {
            if (tmp.getType() == type) {
                return tmp;
            }
        }
        return null;
    }

    public static boolean contains(int type) {
        for (ResourceTypeEnum tmp : ResourceTypeEnum.values()) {
            if (tmp.getType() == type) {
                return true;
            }
        }
        return false;
    }

}
